package cn.com.se.设计模式.享元模式;

public class 享元模式 {
    public static void main(String[] args) {
        // 获取共享棋子对象
        ChessPiece blackPawn = ChessPieceFactory.getPiece("黑", "兵");
        ChessPiece redCar = ChessPieceFactory.getPiece("红", "车");

        // 绘制棋子（外部状态由调用时传入）
        blackPawn.draw(1, 2);
        redCar.draw(3, 4);

        // 再次获取相同棋子不会新建对象
        ChessPiece sameBlackPawn = ChessPieceFactory.getPiece("黑", "兵");
        sameBlackPawn.draw(5, 6);
    }
}
